<template>
    <div class="e-list layout-main">
        <div class="e-list-div">
            <el-button type="primary" icon="el-icon-upload" :loading="uploading" @click="selectFiles">
                上传
            </el-button>
            <el-button type="primary" @click="handleScript" v-preventReClick>
                执行脚本
            </el-button>
            <el-button type="primary" @click="downLoadPdm" v-preventReClick>下载pdm</el-button>

            <el-dropdown
                v-show="hideBtn.visible1"
                split-button
                type="primary"
                @command="handleGlobalScript"
                @click="handleGlobalScript('0')"
                style="margin:0 10px"
            >
                全量脚本
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="1">项目脚本</el-dropdown-item>
                    <el-dropdown-item command="2">产品脚本</el-dropdown-item>
                    <el-dropdown-item command="">自选脚本</el-dropdown-item>
                    <el-dropdown-item command="3">产品增量</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
            <!-- <el-select
                v-model="hiddenSelect.ids"
                multiple
                collapse-tags
                filterable
                size="mini"
                style="margin-left:10px;width:230px"
                v-if="hideBtn.visible && hiddenSelect.funds.length"
                @change="hiddenSelectChange"
            >
                <el-option
                    v-for="fitem in [{ dictKey: '-1', dictKeyName: '选择全部' }].concat(hiddenSelect.funds)"
                    :label="fitem.dictKey + ' ' + fitem.dictKeyName"
                    :value="fitem.dictKey"
                    :key="fitem.dictKey"
                ></el-option> 
            </el-select> -->

            <el-tooltip effect="dark" :content="selectTooltip" :disabled="!selectTooltip" placement="bottom-start">
                <el-select
                    v-model="hiddenSelect.ids"
                    v-show="hideBtn.visible"
                    filterable
                    clearable
                    remote
                    multiple
                    reserve-keyword
                    collapse-tags
                    :remote-method="getScriptList"
                    @clear="getScriptList('')"
                    @change="handleChangeSelect"
                    :loading="selectLoading"
                    size="mini"
                    value-key="id"
                    style="width: 310px"
                >
                    <el-option v-for="item in hiddenSelect.funds" :key="item.id" :label="item.id + ' ' + item.objectName" :value="item"> </el-option>
                </el-select>
            </el-tooltip>
            <!-- <RiskCustomSelect
                :selectKeys="hiddenSelect.ids"
                :dataSource="hiddenSelect.funds"
                v-if="hideBtn.visible && hiddenSelect.funds.length"
                showSelectAll="true"
                @customSelectReturn="customSelectReturn"
                style="margin-left:10px;width:230px;display:inline-block"
            ></RiskCustomSelect> -->
            <el-button type="primary" size="mini" style="margin-left: 10px;" v-show="hideBtn.visible" @click="handleOptionScript">
                导出
            </el-button>
            <el-button type="primary" class="sql-but" @click="openDatabaseDailog">
                数据库
            </el-button>
        </div>
        <div class="e-list-conter">
            <div class="conter-left">
                <el-tree :data="uploadDataTree" ref="uploadDataTree" show-checkbox node-key="fullName" @node-click="handleTreeItemClick">
                    <span class="custom-tree-node" slot-scope="{ data }">
                        <span>
                            <i class="el-icon-folder-opened" v-show="data.folder"></i>
                            <i class="el-icon-document" v-show="!data.folder"></i>
                            <span>&nbsp;{{ data.fileName }}&nbsp;&nbsp;</span>
                            <i
                                class="el-icon-circle-check"
                                style="color: #008000"
                                v-show="filterExecutionStatus(data.folder, 'success', data.fullName)"
                            ></i>
                            <i
                                class="el-icon-circle-close"
                                style="color: #ff0000"
                                v-show="filterExecutionStatus(data.folder, 'error', data.fullName)"
                            ></i>
                        </span>
                    </span>
                </el-tree>
            </div>
            <div class="conter-right">
                <p class="cnoter-text">文件预览:</p>
                <textarea ref="textarea" class="conter-lock" readonly v-model="fileSourceCode" @dblclick="doubleClickSource"></textarea>
                <!-- @blur="blurSource" -->
                <!-- @keydown="showHideButton" -->
                <!-- @focus="showHideButton" -->
                <p class="cnoter-text">执行日志:</p>
                <div class="conter-log">
                    <p v-for="rItem in watchReasult" :key="rItem.fileName" :style="{ color: rItem.success ? 'green' : 'red' }">
                        {{ rItem.fileName }}
                        {{ rItem.success ? ': 执行成功' : ': 执行失败' }}
                        <br />
                        {{ rItem.msg }}
                    </p>
                </div>
            </div>
        </div>
        <el-card class="hidden-box" v-show="showHiddenbox">
            <h2>导出脚本和基础数据</h2>
            <div>
                <el-form label-width="160px" size="mini" label-position="top">
                    <el-form-item label="表名称(不填则导出全部):">
                        <el-select v-model="tableNames" style="width:100%" multiple clearable filterable reserve-keyword>
                            <el-option
                                class="info-dialog-form"
                                v-for="item in tableNamesStorage"
                                :key="item.tableName"
                                :label="item.tableName"
                                :value="item.tableName"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="查询条件(填写where后面的条件):">
                        <el-input v-model="querySql" class="info-dialog-form" />
                    </el-form-item>
                    <el-form-item label="按维度导出字段(大写, 如果不填则导出全部数据, 否则导出数据按维度字段分文件):">
                        <el-input v-model="dimensionField" class="info-dialog-form" />
                    </el-form-item>

                    <el-checkbox v-model="deleteRecord">是否是删除数据</el-checkbox>
                </el-form>
            </div>
            <div class="btn-groups">
                <el-button type="primary" @click="exportTableConstruction" v-preventReClick>导出表结构</el-button>
                <el-button type="primary" @click="exportData" v-preventReClick>导出数据</el-button>
            </div>
        </el-card>
        <div class="conter-dialog">
            <yh-dialog drag title="数据库配置" :visible.sync="databaseConfig.visible" :close-on-click-modal="false" width="600px">
                <el-form ref="form" :model="databaseConfig" label-width="90px" size="mini">
                    <el-form-item label="连接方式：">
                        <el-radio-group v-model="databaseConfig.useJdbcUrl">
                            <el-radio :label="false">默认</el-radio>
                            <el-radio :label="true">JDBC-URL</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="地址：">
                        <el-input class="conter-input" placeholder="连接地址" v-model.trim="databaseConfig.ip" clearable />
                        <span>
                            <el-input
                                class="conter-input-id2"
                                placeholder="端口"
                                v-model.trim="databaseConfig.port"
                                v-show="!databaseConfig.useJdbcUrl"
                            />
                            <el-input
                                class="conter-input-id2"
                                placeholder="实例名"
                                v-model.trim="databaseConfig.serverName"
                                v-show="!databaseConfig.useJdbcUrl"
                            />
                        </span>
                    </el-form-item>
                    <el-form-item label="账号：">
                        <el-input class="conter-input" v-model.trim="databaseConfig.account" placeholder="账号" clearable />
                    </el-form-item>
                    <el-form-item label="密码：">
                        <el-input class="conter-input" v-model.trim="databaseConfig.password" show-password placeholder="密码" clearable />
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button size="mini" type="primary" @click="onsubmitTest()" :loading="databaseConfig.loading">
                        测试连接
                    </el-button>
                    <el-button size="mini" @click="databaseConfig.visible = false">关闭 </el-button>
                </div>
            </yh-dialog>
        </div>
    </div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { UUID, getFileText } from '@/utils/tools';
import { downLoadFile } from '@/utils/request';
import RiskCustomSelect from '@/common/components/risk-custom-select.vue';

@Component({
    name: 'ExecuteList',
    components: {
        RiskCustomSelect,
    },
})
export default class ExecuteList extends Vue {
    private databaseConfig = {
        account: '',
        ip: '',
        serverName: '',
        password: '',
        port: '1521',

        // port: '1521',
        // ip: '192.168.75.51',
        // serverName: 'risk',
        // account: 'dev_risk30',
        // password: 'dev_risk30',
        // account: 'risk30sit',
        // ip: '192.168.75.53',
        // password: 'Yhfincom2016_risk30_sit',
        // port: '1521',
        scriptType: '',
        useJdbcUrl: false,
        visible: false,
        loading: false,
    };

    // 上传的数据
    private uploadDataTree: any[] = [];
    // 上传等待状态
    private uploading: boolean = false;
    // 上传的文件
    private uploadFileList: File[] = [];
    // 上传的父文件夹
    private parentFolder: string = '';

    // 右边显示文件代码
    private fileSourceCode: string = '';

    // 监听脚本执行结果
    private watchReasult: any[] = [];

    // 自选脚本选中状态
    // private optScript: boolean = false;

    // private fullScriptData: any[] = [];
    // // 自选脚本下拉框请求数据
    // private requestData = {
    //     ids: [],
    // };

    // 隐藏按钮功能双击状态
    // 按钮显示条件：必须双击选中，然后同时按 Ctrl + Alt + Shift + S
    private hideBtn = {
        textDClickState: false,
        visible: false,
        keyCode: [null, null, null] as number[],
        visible1: false,
    };

    // 隐藏按钮自选脚本数据
    private hiddenSelect = {
        // 下拉框
        funds: [],
        // 下拉框选中项
        ids: [],
    };

    private tableNames: any[] = [];
    private querySql: string = '';
    private dimensionField: string = '';
    private deleteRecord: boolean = false;
    private showHiddenbox: boolean = false;
    private tableNamesStorage: any[] = [];
    private selectLoading: boolean = false;
    private selectTooltip: string = '';

    mounted() {
        window.addEventListener('keydown', this.handleKeyDown);
        this.getTableNameList();
    }

    destroyed() {
        window.removeEventListener('keydown', this.handleKeyDown);
    }

    // 键盘事件
    private handleKeyDown(e: any): void {
        // e.persist();
        if (e.ctrlKey && e.shiftKey && e.keyCode === 83) {
            this.showHiddenbox = !this.showHiddenbox;
        }
    }

    // 获取所有表名
    private getTableNameList(): void {
        this.$axios({ method: 'get', url: '/common/list/table' }).then((res: any) => {
            this.tableNamesStorage = res;
        });
    }

    // 导出表结构
    private exportTableConstruction() {
        let data = {};
        if (this.tableNames.length !== 0) {
            data = { table: this.tableNames.join(',') };
        }
        downLoadFile({
            method: 'post',
            url: '/export/table/object',
            loading: true,
            loadingMsg: '正在准备导出，请稍后··· ···',
            data,
        });
    }

    // 导出数据
    private exportData() {
        let data = {
            deleteRecord: this.deleteRecord,
            dimensionField: this.dimensionField,
            querySql: this.querySql,
            table: this.tableNames.join(','),
        };
        downLoadFile({
            method: 'post',
            url: '/export/table/data',
            loading: true,
            loadingMsg: '正在准备导出，请稍后··· ···',
            data,
        });
    }

    /**
     * 上传文件
     */
    selectFiles() {
        let inputElement = document.createElement('input');
        inputElement.setAttribute('type', 'file');
        inputElement.setAttribute('webkitdirectory', 'true');
        inputElement.setAttribute('directory', 'true');
        inputElement.setAttribute('accept', '.sql');
        inputElement.setAttribute('multiple', 'true');

        inputElement.addEventListener('change', async e => {
            // 初始化所有数据
            this.resetData();

            const MAX_FILE = 1024 * 1024 * 10;
            const parentFolder = UUID() + '-' + new Date().getTime();
            const url = '/system-maintence/upload/script/' + parentFolder;
            const checkFileType = /.sql$/;

            let files = Array.from((e.target as HTMLInputElement).files).filter(item => checkFileType.test(item.name));

            // 排除大文件
            for (let i = 0; i < files.length; i++) {
                if (files[i].size > MAX_FILE) {
                    this.yh_message_error('文件 ' + files[i].name + ' 大于10MB 不能上传 请排除后重新上传');
                    return;
                }
            }

            // 收集所有请求
            let httpList = [];
            files.forEach(file => {
                const formData = new FormData();
                formData.append('file', file, (file as any).webkitRelativePath);
                httpList.push(
                    this.$axios.post(url, formData, {
                        headers: { 'Content-Type': 'multipart/form-data' },
                    })
                );
            });
            this.uploading = true;
            // 发送请求
            Promise.all(httpList)
                .then(() => {
                    this.$axios
                        .get('/system-maintence/query/script/' + parentFolder)
                        .then((result: any) => {
                            this.uploadFileList = files;
                            this.parentFolder = parentFolder;
                            this.uploadDataTree = this.filterUploadDataTree(result);
                        })
                        .finally(() => {
                            this.uploading = false;
                        });
                })
                .catch(() => {
                    this.uploading = false;
                });
            // 释放内存，防止闭包无法自动删除数据
            inputElement = null;
        });
        inputElement.click();
    }

    /**
     * 处理数据
     */
    filterUploadDataTree(result: any[], fullName?: string) {
        result.forEach(item => {
            let str = fullName;
            if (!str) {
                str = item.fileName;
            } else {
                str = str + '/' + item.fileName;
            }
            item.fullName = str;

            if (item.children && item.children.length) {
                this.filterUploadDataTree(item.children, str);
            }
        });
        return result;
    }

    /**
     * 点击上传列表项，右边显示文字
     * @param data 数据
     * @param node 节点
     */
    handleTreeItemClick(data, node) {
        if (data.folder) {
            return;
        }
        this.uploadFileList.forEach(async (file: any) => {
            if (node.key === file.webkitRelativePath) {
                let msg;
                try {
                    msg = await getFileText(file);
                } catch (e) {
                    msg = e;
                }
                this.fileSourceCode = msg;
            }
        });
    }

    // 验证数据库配置项是否正确
    private verifyConnect(): boolean {
        const config = this.databaseConfig;
        let verifyJdbcUrl = config.useJdbcUrl && config.ip && config.account && config.password;
        let verifyDefault = !config.useJdbcUrl && config.ip && config.account && config.password && config.port && config.serverName;
        let retValue = true;
        if (!verifyJdbcUrl && !verifyDefault) {
            this.yh_message_error('数据库配置项不正确');
            retValue = false;
        }
        return retValue;
    }

    /**
     * 执行脚本
     */
    async handleScript() {
        const config = this.databaseConfig;
        if (!this.verifyConnect()) {
            return;
        }

        // sql脚本列表
        const scripts = (this.$refs.uploadDataTree as any).getCheckedKeys().filter((str: string) => /.sql$/.test(str));
        if (!scripts || !scripts.length) {
            this.yh_message_error('未选择脚本');
            return;
        }

        // 验证连接是否可行
        // let validation = await this.onsubmitTest(true);
        // if (!validation) {
        //     return;
        // }

        const data = {
            ip: config.ip,
            port: config.port,
            serverName: config.serverName,
            account: config.account,
            password: config.password,
            useJdbcUrl: config.useJdbcUrl,
            parentFolder: this.parentFolder,
            scripts,
        };

        // 开始
        this.$axios.post('/system-maintence/run/script', data).then((result: any) => {
            for (let i = 0; i < 5; i++) {
                if (i === 0) {
                    this.watchHandleScriptResult(this.parentFolder);
                    continue;
                }
                setTimeout(() => {
                    this.watchHandleScriptResult(this.parentFolder);
                }, 2000 * (i + 1));
            }
        });
    }

    // 下载pdm
    downLoadPdm() {
        downLoadFile({
            method: 'get',
            url: '/system/export/script/pdm',
            loading: true,
            loadingMsg: '正在准备导出，请稍后··· ···',
        });
    }

    /**
     * 监听执行脚本结果
     * @param parentFolder 虚拟文件夹
     */
    watchHandleScriptResult(parentFolder: string) {
        return new Promise((resolve, reject) => {
            // /system-maintence/run/progress/
            this.$axios.get('/system/run/progress/' + parentFolder).then((result: any) => {
                this.watchReasult = result;
            });
        });
    }

    /**
     * 过滤脚本结果，用于显示文件状态
     * @param folder    是否是文件夹
     * @param type      成功图标: 'success'  失败图标: 'error'
     * @param fullName  文件全名（唯一键）
     */
    filterExecutionStatus(folder: boolean, type: string, fullName: string): boolean {
        if (folder) {
            return false;
        }
        let state = false;
        for (let i = 0; i < this.watchReasult.length; i++) {
            let item = this.watchReasult[i];
            if (item.fileName === fullName && item.success === true && type === 'success') {
                state = true;
                break;
            } else if (item.fileName === fullName && item.success === false && type === 'error') {
                state = true;
                break;
            }
        }
        return state;
    }

    /**
     * 打开数据库配置弹窗
     */
    openDatabaseDailog(): void {
        this.databaseConfig.visible = true;
        this.getDefaultDataBaseConfigure();
    }

    // 获取默认数据连接配置
    private getDefaultDataBaseConfigure() {
        this.$axios.get('/system/getDefaultDataBaseConfig').then((res: any) => {
            if (res && res !== {}) {
                let jdbcUrl = res['jdbcUrl'].split(':');
                this.databaseConfig['account'] = res['username'];
                this.databaseConfig['password'] = res['password'];
                this.databaseConfig['serverName'] = jdbcUrl[5] || res['jdbcUrl'].split('/')[1];
                this.databaseConfig['ip'] = jdbcUrl[3].substring(1);
            }
            console.log(this.databaseConfig, 'databaseConfig');
        });
    }

    /**
     * 测试连接
     * @param ski 是否跳过提示
     */
    onsubmitTest(ski?: boolean) {
        // if (!this.verifyConnect()) {
        //     return Promise.resolve(false);
        // }

        const data = { ...this.databaseConfig };
        delete data.visible;
        delete data.loading;

        this.databaseConfig.loading = true;
        return this.$axios
            .post('/system/test/database/connection', data)
            .then(res => {
                if (ski !== true) {
                    this.yh_message_success('连接成功!');
                }
                this.databaseConfig.loading = false;
                return Promise.resolve(true);
            })
            .catch(e => {
                this.databaseConfig.loading = false;
                // eslint-disable-next-line prefer-promise-reject-errors
                return Promise.resolve(false);
            });
    }

    /**
     * 数据初始化
     */
    resetData(): void {
        this.uploadDataTree = [];
        this.uploadFileList = [];
        this.parentFolder = '';

        this.fileSourceCode = '';
        this.watchReasult = [];
    }

    // 隐藏功能按钮 - 双击源代码文本框
    doubleClickSource(): void {
        this.hideBtn.textDClickState = true;
        if (this.hideBtn.visible1) {
            this.hideBtn.visible = false;
        }
        this.hideBtn.visible1 = this.hideBtn.visible1 != true;
        // this.hiddenSelect.funds = [];
        this.hiddenSelect.ids = [];
    }

    // 隐藏功能按钮 - 源代码文本框取消聚焦
    blurSource(): void {
        this.hideBtn.textDClickState = false;
    }

    // 隐藏功能按钮 - 显示隐藏按钮
    showHideButton(event) {
        if (!this.hideBtn.textDClickState) {
            return;
        }

        const keyCode: number = event.keyCode || event.code;
        console.log(keyCode, 'keyCode');

        // Ctrl(16) + Alt + Shift(17) + S
        switch (keyCode) {
            case 17:
                if (this.hideBtn.keyCode.includes(keyCode)) {
                    return;
                } else {
                    this.hideBtn.keyCode[0] = keyCode;
                }
                break;
            // case 18:
            //     if (this.hideBtn.keyCode.includes(keyCode)) {
            //         return;
            //     } else {
            //         this.hideBtn.keyCode[1] = keyCode;
            //     }
            //     break;
            case 16:
                if (this.hideBtn.keyCode.includes(keyCode)) {
                    return;
                } else {
                    this.hideBtn.keyCode[1] = keyCode;
                }
                break;
            case 83:
                if (this.hideBtn.keyCode.includes(keyCode)) {
                    return;
                } else {
                    this.hideBtn.keyCode[2] = keyCode;
                }
                break;
            default:
                this.$set(this.hideBtn, 'keyCode', [null, null, null]);
                return;
        }
        if (!this.hideBtn.keyCode.includes(null)) {
            this.hideBtn.visible = true;
            this.$set(this.hideBtn, 'keyCode', [null, null, null]);
            // this.hiddenSelect.funds = [];
            this.hiddenSelect.ids = [];
        }
    }

    // 隐藏选中项监听
    hiddenSelectChange(value) {
        if (value.includes('-1')) {
            this.yh_message_success('选择全选后,其他选项自动清空');
            this.hiddenSelect.ids = ['-1'];
        }
    }

    // 获取脚本列表
    private getScriptList(dictKey: string): any {
        this.selectLoading = true;
        // 自选脚本down
        const config = this.databaseConfig;
        if (!this.verifyConnect()) {
            return;
        }
        const data = {
            ip: config.ip,
            port: config.port,
            serverName: config.serverName,
            account: config.account,
            password: config.password,
            useJdbcUrl: config.useJdbcUrl,
            scriptType: '',
            objectName: dictKey,
        };
        return new Promise((resolve, reject) => {
            this.$axios
                .post('/system/getFullScript', data)
                .then((res: any) => {
                    this.selectLoading = false;
                    this.hiddenSelect.funds = res;
                    this.hideBtn.visible = true;
                    resolve(res);
                })
                .catch(err => {
                    this.selectLoading = false;
                    this.hiddenSelect.funds = [];
                    reject(err);
                });
        });
    }

    // 隐藏功能按钮 - 按钮点击下载
    async handleGlobalScript(type: string) {
        // let validation = await this.onsubmitTest(true);

        // if (!validation) {
        //     return;
        // }

        // 产品增量
        if (type === '3') {
            if (!this.uploadDataTree.length) {
                this.yh_message_warn('上传脚本后进行生成');
                return;
            }
            downLoadFile({
                url: '/system/create/script/' + this.parentFolder,
                loading: true,
                loadingMsg: '正在准备导出，请稍后··· ···',
            });
        } else if (type === '') {
            // 自选脚本down
            this.getScriptList('');
            // const config = this.databaseConfig;
            // if (!this.verifyConnect()) {
            //     return;
            // }
            // const data = {
            //     ip: config.ip,
            //     port: config.port,
            //     serverName: config.serverName,
            //     account: config.account,
            //     password: config.password,
            //     useJdbcUrl: config.useJdbcUrl,
            //     scriptType: type,
            // };
            // this.$axios
            //     .post('/system/getFullScript', data)
            //     .then((res: any) => {
            //         let funds = [];
            //         if (res && res.length) {
            //             funds = res.map((item, index) => {
            //                 return { dictKey: item.id.toString(), dictKeyName: item.objectName };
            //             });
            //         }
            //         if (!funds.length) {
            //             this.yh_message_error('没有查询到数据');
            //         }
            //         this.hiddenSelect.funds = funds;
            //         // this.hiddenSelect.funds = [
            //         //     {
            //         //         dictKey: '1',
            //         //         dictKeyName: 'xxxx',
            //         //     },
            //         //     {
            //         //         dictKey: '2',
            //         //         dictKeyName: 'yyyyyy',
            //         //     },
            //         // ];
            //         this.hideBtn.visible = true;
            //     })
            //     .catch(e => {
            //         this.hiddenSelect.funds = [];
            //     });
        } else {
            // 默认点击0  项目脚本1  产品脚本2
            const config = this.databaseConfig;
            if (!this.verifyConnect()) {
                return;
            }
            const data = {
                ip: config.ip,
                port: config.port,
                serverName: config.serverName,
                account: config.account,
                password: config.password,
                useJdbcUrl: config.useJdbcUrl,
                scriptType: type,
            };
            downLoadFile({
                method: 'post',
                url: '/system/create/full/script',
                loading: true,
                loadingMsg: '正在准备导出，请稍后··· ···',
                data,
            });
        }
    }
    /**
     * 处理自选脚本选中内容
     */
    async handleOptionScript() {
        let ids = this.hiddenSelect.ids;
        if (!ids || !ids.length) {
            this.yh_message_error('未选择脚本');
            return;
        }
        let arr = ids.map(item => item.id);
        // 如果为全选 则发送全部
        if (arr.some(id => id === '-1')) {
            this.handleGlobalScript('1');
        } else {
            let exportObjects = ids;
            const config = this.databaseConfig;
            if (!this.verifyConnect()) {
                return;
            }
            const data = {
                ip: config.ip,
                port: config.port,
                serverName: config.serverName,
                account: config.account,
                password: config.password,
                useJdbcUrl: config.useJdbcUrl,
                scriptType: '3',
                exportObjects: exportObjects,
            };
            downLoadFile({
                url: '/system/create/full/script',
                method: 'post',
                data: data,
                loading: true,
                loadingMsg: '正在准备导出，请稍后··· ···',
            });
        }
    }

    private handleChangeSelect(val: any): void {
        console.log(val, '!@!@!');

        this.selectTooltip = val.map(item => item.objectName).join(',');
        console.log(this.selectTooltip, 'selectTooltip');
    }

    // private customSelectReturn(value: any): void {
    //     this.hiddenSelect.ids = value;
    // }
}
</script>
<style lang="scss" scoped>
.e-list {
    .e-list-div {
        border: 1px solid #eee;
        padding: 8px;
        // display: flex;

        .sql-but {
            float: right;
        }

        & /deep/ {
            .el-dropdown__caret-button span {
                min-width: auto;
            }
        }

        & /deep/ .el-select__tags {
            flex-wrap: nowrap;

            .el-tag.el-tag--info {
                max-width: 180px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
        }
    }

    .hidden-box {
        margin: 10px 0;

        h2 {
            font-size: 18px;
            font-weight: 500;
            text-align: center;
        }

        /deep/ .el-form-item__label {
            color: #575757;
        }

        .btn-groups {
            margin-top: 10px;
        }
    }

    .e-list-conter {
        border: 1px solid #eee;
        margin-top: 10px;
        height: calc(100vh - 130px);
        position: relative;

        .conter-left {
            width: 50%;
            height: 100%;
            border-right: 1px solid #eee;
        }

        .conter-right {
            width: 50%;
            position: absolute;
            right: 0;
            top: 0;

            .cnoter-text {
                font-weight: bold;
            }

            .conter-lock,
            .conter-log {
                display: block;
                border: 1px solid #eee;
                padding: 5px;
                overflow-y: auto;
            }

            .conter-lock {
                height: 50vh;
                width: 100%;
                resize: none;

                &:focus {
                    border-color: #000;
                }
            }

            .conter-log {
                height: calc(50vh - 175px);
            }
        }
    }
    .conter-dialog {
        .conter-input {
            width: 250px;
        }

        .conter-input-id2 {
            width: 80px;
            margin-left: 5px;
        }
    }
}
</style>
